package org.study.enums;

/**
 * 枚举类在实际项目中的应用示例：订单状态机
 * 参考 https://blog.csdn.net/MeyrlNotFound/article/details/147870300
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年07月16日
 */
public class OrderStatusEnumTest {
    public static void main(String[] args) {

    }

    public enum OrderStatus {
        CREATED {
            @Override
            public OrderStatus next() {
                return PAID;
            }

            @Override
            public boolean canCancel() {
                return true;
            }
        },
        PAID {
            @Override
            public OrderStatus next() {
                return SHIPPED;
            }

            @Override
            public boolean canCancel() {
                return true;
            }
        },
        SHIPPED {
            @Override
            public OrderStatus next() {
                return DELIVERED;
            }

            @Override
            public boolean canCancel() {
                return false;
            }
        },
        DELIVERED {
            @Override
            public OrderStatus next() {
                return this;
            }

            @Override
            public boolean canCancel() {
                return false;
            }
        },
        CANCELLED {
            @Override
            public OrderStatus next() {
                return this;
            }

            @Override
            public boolean canCancel() {
                return false;
            }
        };

        public abstract OrderStatus next();

        public abstract boolean canCancel();
    }
}
